package me.minecraft.plugin.itemsave;

import me.minecraft.plugin.itemsave.command.MainCommand;
import me.minecraft.plugin.itemsave.config.MainConfig;
import me.minecraft.plugin.itemsave.config.MessageConfig;
import me.minecraft.plugin.itemsave.manager.ItemManager;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.PluginCommand;
import org.bukkit.plugin.java.JavaPlugin;

public final class ItemSave extends JavaPlugin {

    public static ItemSave instance;

    @Override
    public void onEnable() {
        instance = this;
        MainConfig.INSTANCE.load();
        MessageConfig.INSTANCE.load();
        ItemManager.INSTANCE.load();
        registerCommand("ItemSave", new MainCommand());
    }

    private void registerCommand(String name, CommandExecutor executor) {
        PluginCommand command = getCommand(name);
        if (command == null) {
            getLogger().warning("无法注册命令：" + name);
            return;
        }
        command.setExecutor(executor);
    }

}
